﻿using Archiecture.API.Application.Commands.DeepCommand;
using Architecture.Domain.Dto.Source;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swork03_28.Api.Application.Commands.DeepCommand;
using Swork03_28.Domain.TraceableInfos;

namespace Archiecture.API.Controllers
{
    /// <summary>
    /// 深加工信息管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class DeepProcessController : ControllerBase
    {
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造方法注入
        /// </summary>
        /// <param name="mediator"></param>
        public DeepProcessController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取深加工信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<DeepProcess> GetDeepProcess([FromQuery] GetDeepProcessCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 添加深加工信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CreateDeepProcess(CreateDeepProcessCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 修改深加工信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateDeepProcess(UpdateDeepProcessCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取食品安全信息质图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<ImgDto>> GetCertificationList([FromQuery] CertificationListCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 操作图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> OperationImg([FromQuery] CeOperationImgCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 添加深加工公司信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> DeepFirmCreate(DeepFirmCreateCommand command)
        {
            return await (_mediator.Send(command));
        }

        /// <summary>
        /// 获取公司信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<FirmInfo> DeepFirmSelect([FromQuery] DeepFirmSelectCommand command)
        {
            return await _mediator.Send<FirmInfo>(command);
        }

        /// <summary>
        /// 添加深加工公司图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> DeepFirmImgCreate([FromQuery]DeepFirmImgCreateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 删除深加工公司图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeepFirmImgDelete([FromQuery]DeepFirmImgDeleteCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
